package com.ruoyi.crm.modules.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CrmRabbitConfig {
    public static final String CRM_QUEUE_CONTRACT_CREATED = "crm_queue_contract_created";
    public static final String CRM_EXCHANGE_CONTRACT = "crm_exchange_contract";
    public static final String CRM_ROUTING_KEY_CONTRACT_CREATED = "crm.routing.key.contract.created";

    @Bean
    public Queue crmContractCreatedQueue() {
        return new Queue(CRM_QUEUE_CONTRACT_CREATED);
    }

    @Bean
    public DirectExchange crmContractDirectExchange() {
        return new DirectExchange(CRM_EXCHANGE_CONTRACT);
    }

    @Bean
    public Binding crmContractBinding(Queue crmContractCreatedQueue, DirectExchange crmContractDirectExchange) {
        return BindingBuilder.bind(crmContractCreatedQueue).to(crmContractDirectExchange).with(CRM_ROUTING_KEY_CONTRACT_CREATED);
    }
}
